package yangbajing.util

import scala.xml.{NodeSeq, Unparsed}
import net.liftweb.markdown.Transformer
import net.liftweb.util.Helpers._

object MarkdownHelpers {
  private val transformer = new Transformer {}

  def parseToNodeSeq(content: String): NodeSeq =
    parseToNodeSeq(content, in => ("a [target]" #> "_blank") apply in)

  def parseToNodeSeq(content: String, func: NodeSeq => NodeSeq): NodeSeq = {
    val result = Unparsed(parseToString(content))
    func(result)
  }

  def parseToString(content: String): String =
    transformer(content)
}
